<template>
    <div id="app">
        <el-row>
            <el-col :span="12" :offset="6"><div class="grid-content">

                <el-card class="box-card" shadow="never">
                    <div class="text item"><i class="el-icon-s-marketing" style="color: darkcyan"></i>提交学习记录</div>
                    <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="120px" class="demo-ruleForm">
                        <el-form-item label="用户账号：" prop="account">
                            <el-input v-model="ruleForm.account" placeholder="请输入用户的账号"></el-input>
                        </el-form-item>
                        <el-form-item label="用户姓名：" prop="name">
                            <el-input v-model="ruleForm.name" placeholder="请输入用户的姓名"></el-input>
                        </el-form-item>
                        <el-form-item>
                            <el-button type="primary" @click="submitForm('ruleForm')">进入</el-button>
                            <el-button @click="resetForm('ruleForm')">重置</el-button>
                        </el-form-item>
                    </el-form>
                </el-card>
            </div></el-col>
        </el-row>
    </div>
</template>

<script>
    export default {
        name: "appointmentsectionchoose",
        data() {
            return {
                timer:null,
                ruleForm: {
                    account: '',
                    name: '',
                },
                rules: {
                    account: [
                        { required: true, message: '请输入用户姓名', trigger: 'blur' },
                    ],
                    name: [
                        { required: true, message: '请输入用户姓名', trigger: 'blur' },
                        { min: 2, max: 10, message: '长度在 2 到 10 个字符', trigger: 'blur' }
                    ],
                }
            };
        },
        created() {

        },
        methods: {
            submitForm(formName) {
                this.$refs[formName].validate((valid) => {
                    if (valid) {
                        this.query();

                    } else {
                        return false;
                    }
                });
            },
            resetForm(formName) {
                this.$refs[formName].resetFields();
            },

            query(){
                this.$router.push({path:'/learnAndSubmit',query:{account:this.ruleForm.account,name:this.ruleForm.name}});
            }

        },
    }
</script>

<style scoped>
    .text {
        font-size: 18px;
    }

    .item {
        margin-bottom: 20px;
    }
    .box-card{
        margin-top: 20px;
    }
</style>